﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tilver.Coder;
using Tilver.Coder.Core;

namespace Tilver.Test.Coder
{
    public class LoadDataProject
    {
        public static CoderProject Project { get; set; }
        /// <summary>
        /// 加载数据库项目
        /// </summary>
        public void LoadProject()
        {
            var _project = new CoderProject
                {
                    Author = "landy",
                    CreateDate = DateTime.Now,
                    ModifyDate = DateTime.Now,
                    Name = "Tilver",
                    NameSpace = "Tilver.com",
                    SaveDirectory = @".\DAL",
                    DataBases = new List<CoderDataBase>()
                        {
                            new CoderDataBase()
                                {
                                    //ConnectionString = "Data Source=.;Initial Catalog=TilverDB;Integrated Security=True",
                                    ConnectionString = "Data Source=localhost;Initial Catalog=tilverdb;User ID=root;Password=landy",
                                    DataProviderType = DataProviderTypeEnum.MySQL
                                }
                        }
                };
            Project = _project;
            var loader = new DataLoader { Project = _project };
            foreach (var coderDataBase in _project.DataBases)
            {
                loader.LoadDataBase(coderDataBase);
            }
        }
    }
}
